capture log close
log using crisis_rep_2020common, replace text
//program:  crisis_rep_2020common.do
//task:    Replication of 2020 CCES Common Content analyses
//project: Politics of Personal Crisis (Ojeda, Michener & Haselswerdt), Political Behavior     
//author: Jake Haselswerdt \ 2024-3-7

//program setup
version 15
clear all
set linesize 80
macro drop _all
set scheme s1color
graph set window fontface "GillSans"
set more off

use CCES20_common_crisis_vv.dta, clear
svyset [pw=commonweight]
global controls "voted2016_valid female black hisp other age educ income married churchattend child18_01"

//Appendix C: Descriptives
foreach c in crisis_income crisis_jobloss crisis_divorce crisis_victim crisis_er crisis_paycut crisis_covidself crisis_covidfam crisis_covidfriend crisis_covidcoworker crisis_covidfamdeath crisis_covidfrienddeath crisis_covidcoworkerdeath crisis_covidhrs crisis_covidlayoff{
di "`: var label `c''"
svy: proportion `c'
}
svy: proportion total_crises

sum voted_valid total_crises covid_crises other_crises $controls [aw=commonweight]


// Figure 1: Histogram/Frequency Distribution
graph twoway (hist total_crises, discrete percent fcolor(gs10) lcolor(white)), ///
	title("CES 2020 Common") ///
	xtitle("Count of Negative Life Events") ///
	xlabel(0 3 6 9 12 15, labsize(2.5)) ///
	xtick(0(3)15) ///
	ytitle("Percentage of Respondents") ///
	ylabel(0(10)70, labsize(2.5) angle(horizontal)) ///	
	yscale(titlegap(2)) ///
	xscale(titlegap(2)) ///
	graphregion(fcolor(white)) ///
	scheme(s1mono) graphregion(fcolor(white)) aspect(1) ///
	saving(cces20cc_hist, replace)

// Table 2 / Appendix D: T-test Results
	
* Non-COVID Crises
foreach var of varlist crisis_income crisis_jobloss crisis_divorce crisis_victim crisis_er crisis_paycut {
di ""
di "`:variable label `var''"
ttest voted_valid, by(`var')
di ""
}

* COVID Crises
foreach var of varlist crisis_covidself crisis_covidfam crisis_covidfriend crisis_covidcoworker crisis_covidfamdeath crisis_covidfrienddeath crisis_covidcoworkerdeath crisis_covidhrs crisis_covidlayoff{
di ""
di "`:variable label `var''"
ttest voted_valid, by(`var')
di ""
}

// Table 3: Cross-tabulation of crisis terciles with voting 
tab lomedhi_covid, sum(covid_crises)
svy: tab voted_valid lomedhi_covid, col 
tab lomedhi_other, sum(other_crises)
svy: tab voted_valid lomedhi_other, col 

// Table 4 & Appendix E: Logistic regressions of voting on personal crisis
svy: logit voted_valid other_crises covid_crises $controls

// Table 5: Models of other participation

*Total count of non-voting participation acts
svy: reg total_part total_crises $controls

*Individual non-voting participation acts
foreach act in meeting sign work protest contact donate{
di " "
di "`:variable label part_`act''"
svy: logit part_`act' total_crises $controls
}

// Appendix F: Demographics and Crises
tab female [aw=commonweight], sum(total_crises)

gen age_cat = .
replace age_cat = 1 if age < 36
replace age_cat = 2 if age > 35
replace age_cat = 3 if age > 55
tab age_cat [aw=commonweight], sum(total_crises)
drop age_cat

gen race_new = race
recode race_new 5=4 6=4 7=4 8=4
tab race_new [aw=commonweight], sum(total_crises)
drop race_new

gen educ_degree = educ
recode educ_degree 4=4 5=4 6=4
tab educ_degree [aw=commonweight], sum(total_crises)
drop educ_degree

xtile income_quintile = income, nq(5)
tab income_quintile [aw=commonweight], sum(total_crises)
drop income_quintile

//Appendix G: Heterogeneous effects
 
*Dichotomous
foreach v in voted2016_valid female white black hisp child18_01{
di "`: var label `v''"
svy: logit voted_valid c.covid_crises##i.`v' c.other_crises##i.`v' $controls
}

*Continuous/ordinal
foreach v in age income educ {
di "`: var label `v''"
svy: logit voted_valid c.covid_crises##c.`v' c.other_crises##c.`v' $controls
}

//Appendix - excluding potentially problematic controls - may or may not bother with this
svy: logit voted_valid total_crises voted2016_valid educ female black hisp other age 
svy: logit voted_valid covid_crises other_crises voted2016_valid educ female black hisp other age 

//Appendix (maybe) - political interest as dependent variable - added 1/23/23
svy: ologit pol_interest other_crises covid_crises $controls
est sto interest
esttab interest, b(2) se(2) onecell star(+ .10 * .05 ** .01) nogaps

svy: reg media_use_index other_crises covid_crises $controls
svy: poisson media_use_index other_crises covid_crises $controls

//For POBE R&R - "placebo" test with 2016 vote 
svy: logit voted2016_valid other_crises covid_crises female black hisp other age educ income married churchattend child18_01

log close
exit
